home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softdisk Supreme
/
Softdisk Supreme.iso
/
pc
/
DSK Files
/
0-49
/
SD022b.dsk
/
GAS MILEAGE.bas
< prev
next >
Wrap
BASIC Source File
|
2003-06-12
|
9KB
|
229 lines
100 REM * PROGRAM BY DARREL RAINES 06/27/83 *
110 LOMEM: 16385:D$ = CHR$(4)
120 PRINT D$;"BRUN CONVERT.OBJ"
130 HOME
140 VTAB 12: INPUT "FOR WHICH CAR DO YOU WISH TO MAKE AN ANALYSIS? ";NM$
150 IF NM$ = "" THEN HOME : GOTO 7000
160 ONERR GOTO 800
170 PRINT D$;"OPEN ";NM$;" MILEAGE.DATA,L6"
180 PRINT D$;"READ ";NM$;" MILEAGE.DATA,R0"
190 TF = USR(DU):IM = USR(DU)
200 POKE 216,0
210 PRINT D$;"READ ";NM$;" MILEAGE.DATA,R";(TF *2 +2)
220 TG = USR(DU):TM = USR(DU):LA = USR(DU):HA = USR(DU):EA = USR(DU)
230 PRINT D$
240 HOME
250 INVERSE : HTAB 15: PRINT "GAS MILEAGE": NORMAL : PRINT
260 PRINT "YOU HAVE ENTERED ";TF;" RECORDS TO DATE.": PRINT : PRINT
270 PRINT "WOULD YOU LIKE TO:": PRINT
280 PRINT " 1 ENTER DATA": PRINT
290 PRINT " 2 EDIT DATA": PRINT
300 PRINT " 3 CALCULATE LIFETIME AVERAGE": PRINT
310 PRINT " 4 CALCULATE AVERAGE FOR LAST TEN": PRINT
320 PRINT " 5 PERFORM NUMERICAL ANALYSIS": PRINT
330 PRINT " 6 PERFORM GRAPHICAL ANALYSIS": PRINT
340 PRINT " 7 EXIT": PRINT
350 VTAB 22: PRINT "PRESS SELECTION NUMBER -- ";: GET SN$:SN = VAL(SN$): PRINT SN
360 IF (SN >0) AND (SN <8) THEN 400
370 VTAB 21: INVERSE : PRINT "<CTRL-G>INVALID ENTRY, PLEASE TRY AGAIN...": NORMAL
380 CALL -958
390 GOTO 350
400 HOME
410 ON SN GOTO 1000,2000,3000,4000,5000,6000,7000
800 HOME
810 PRINT D$;"OPEN ";NM$;" MILEAGE.DATA,L6"
820 PRINT "YOU HAVE NEVER ENTERED DATA ON THIS CAR": PRINT "BEFORE. DO YOU WISH TO START A FILE? ";: GET SN$: PRINT SN$: PRINT
830 IF SN$ < >"Y" THEN HOME : PRINT D$;"DELETE ";NM$;" MILEAGE.DATA": GOTO 7010
840 INPUT "PLEASE ENTER INITIAL MILEAGE: ";IM: PRINT
850 INPUT "WHAT DO YOU CONSIDER TO BE A NORMAL MILES/GALLON AVERAGE FOR THIS CAR: ";EA
860 TG = 0:TM = 0:HA = -1:LA = 5000
870 PRINT D$;"WRITE ";NM$;" MILEAGE.DATA,R0"
880 DU = USR(0):DU = USR(IM):DU = USR(TG):DU = USR(TM):DU = USR(LA):DU = USR(HA):DU = USR(EA)
890 PRINT D$;"CLOSE ";NM$;" MILEAGE.DATA"
900 GOTO 170
1000 HTAB 16: INVERSE : PRINT "DATA ENTRY": NORMAL
1010 VTAB 20: PRINT "MILE.";: HTAB 15: PRINT "GAL.";: HTAB 30: PRINT "AVE."
1020 PRINT "-----";: HTAB 15: PRINT "----";: HTAB 30: PRINT "----"
1030 PRINT D$;"READ ";NM$;" MILEAGE.DATA,R";(TF *2 +1)
1040 LM = USR(DU)
1050 PRINT D$
1060 M = LM:G = 0:A = 0: POKE 34,2: POKE 35,17
1070 VTAB 22: CALL -868
1080 PRINT M;: HTAB 15: PRINT G;: HTAB 30: PRINT A
1090 HOME
1100 INPUT "ENTER NEW MILEAGE (0=EXIT) -- ";M
1110 IF M = 0 THEN 1240
1120 INPUT "ENTER GALLONS OF GASOLINE -- ";G
1130 IF G = 0 THEN A = 0: GOTO 1180
1140 A = (M -LM)/G
1150 TG = TG +G:TM = (M -LM) +TM
1160 IF (A <LA) THEN LA = A
1170 IF (A >HA) THEN HA = A
1180 TF = TF +1
1190 PRINT D$;"WRITE ";NM$;" MILEAGE.DATA,R";(TF *2)
1200 DU = USR(G):DU = USR(M)
1210 PRINT D$
1220 LM = M
1230 GOTO 1070
1240 PRINT D$;"WRITE ";NM$;" MILEAGE.DATA,R";(TF *2 +2)
1250 DU = USR(TG):DU = USR(TM):DU = USR(LA):DU = USR(HA):DU = USR(EA)
1260 PRINT D$;"WRITE ";NM$;" MILEAGE.DATA,R0"
1270 DU = USR(TF)
1280 PRINT D$
1290 TEXT : GOTO 240
2000 HTAB 15: INVERSE : PRINT "DATA EDITING": NORMAL : PRINT
2010 POKE 34,2
2020 IF TF = 0 THEN 4030
2030 PRINT "THERE HAVE BEEN ";TF;" FILL-UPS IN THIS"
2040 INPUT "CAR. EDIT WHICH ONE? ";FF
2050 IF (FF <1) OR (FF >TF) THEN INVERSE : PRINT "INVALID ENTRY NUMBER...": NORMAL : PRINT : GOTO 2030
2060 PRINT D$;"READ ";NM$;" MILEAGE.DATA,R";(FF *2 -1)
2070 LM = USR(DU):OG = USR(DU):OM = USR(DU):NG = USR(DU):NM = USR(DU)
2080 PRINT D$
2090 IF OG = 0 THEN A = 0: GOTO 2110
2100 A = (OM -LM)/OG
2110 HOME
2120 HTAB 15: PRINT "OLD VALUES:"
2130 HTAB 18: PRINT "MILEAGE -- ";OM
2140 HTAB 18: PRINT "GALLONS -- ";OG
2150 HTAB 18: PRINT "AVERAGE -- ";A: PRINT
2160 HTAB 18: PRINT "HIGH -- ";HA
2170 HTAB 18: PRINT "LOW -- ";LA: PRINT : PRINT
2180 PRINT "NEW VALUES:"
2190 INPUT " MILEAGE (0=EXIT) -- ";M
2200 IF M = 0 THEN POKE 34,0: GOTO 240
2210 INPUT " GALLONS -- ";G
2220 TG = TG -OG +G:TM = TM +((M -OM) *((NG = 0) OR (TF = FF))) +((OM -M) *((G = 0) AND (NG < >0)))
2230 PRINT D$;"WRITE ";NM$;" MILEAGE.DATA,R";(FF *2)
2240 DU = USR(G):DU = USR(M)
2250 OM = M:OG = G: IF (G = 0) OR (NG = 0) THEN GOSUB 2500: GOTO 2270
2260 IF (A = HA) OR (A = LA) OR (((M -LM)/G) >HA) OR (((M -LM)/G) <LA) OR (((NM -M)/NG) >HA) OR (((NM -M)/NG) <LA) THEN GOSUB 2500
2270 PRINT D$;"WRITE ";NM$;" MILEAGE.DATA,R";(TF *2 +2)
2280 DU = USR(TG):DU = USR(TM):DU = USR(LA):DU = USR(HA)
2290 PRINT D$
2300 GOTO 2090
2500 HA = -1:LA = 5000
2510 PRINT D$;"READ ";NM$;" MILEAGE.DATA,R1"
2520 L = USR(DU)
2530 FOR I = 1 TO TF
2540 G = USR(DU):M = USR(DU)
2550 IF G = 0 THEN 2590
2560 A = (M -L)/G
2570 IF (A >HA) THEN HA = A
2580 IF (A <LA) THEN LA = A
2590 L = M
2600 NEXT I
2610 RETURN
3000 HTAB 13: INVERSE : PRINT "LIFETIME AVERAGE": NORMAL : PRINT
3010 IF TG = 0 THEN 4030
3020 PRINT "MILES -- ";TM
3030 PRINT "GALLONS -- ";TG
3040 A = TM/TG
3050 PRINT "AVERAGE -- ";A
3060 PRINT : PRINT
3070 HTAB 20: PRINT "HIGH -- ";HA
3080 HTAB 20: PRINT "LOW -- ";LA
3090 PRINT : PRINT
3100 GOSUB 3500
3110 PRINT : GOSUB 4500
3120 GOTO 240
3500 A = 1 +(A >(EA -4.5)) +(A >(EA -1.5)) +(A >(EA +1.5)) +(A >(EA +4.5)) +(A >(EA +7.5))
3510 ON A GOTO 3520,3540,3560,3580,3600,3620
3520 PRINT "FAIRLY POOR AVERAGE. YOU BETTER TAKE": PRINT "A SECOND JOB TO HELP BUY GAS.": PRINT
3530 RETURN
3540 PRINT "NOT A VERY GOOD AVERAGE. SOMETHING": PRINT "COULD BE WRONG -- MAYBE YOUR DRIVING!": PRINT
3550 RETURN
3560 PRINT "GOOD AVERAGE. NOW DON'T SCREW IT UP": PRINT "BY MESSING AROUND.": PRINT
3570 RETURN
3580 PRINT "VERY GOOD AVERAGE. SOMETHING IS SURE": PRINT "TO GO WRONG WITH YOUR CAR NOW.": PRINT
3590 RETURN
3600 PRINT "EXCELLANT AVERAGE. BUT WHO ARE YOU": PRINT "TRYING TO FOOL -- ME OR YOURSELF?": PRINT
3610 RETURN
3620 PRINT "FANTASTIC AVERAGE! YOU ARE EITHER": PRINT "CHEATING OR YOU LEARNED TO DRIVE BETTER.";: PRINT
3630 RETURN
4000 HTAB 12: INVERSE : PRINT "AVERAGE FOR LAST TEN": NORMAL : PRINT
4010 POKE 34,2
4020 IF TF >9 THEN LF = TF:FF = LF -9: GOTO 5040
4030 FLASH : PRINT "SORRY";: NORMAL
4040 PRINT ", THERE ARE NOT ENOUGH ENTRIES TO": PRINT "ALLOW THIS CALCULATION...": PRINT
4050 GOSUB 4500: POKE 34,0: GOTO 240
4500 PRINT "HIT ANY KEY TO CONTINUE -- ";: GET A$: PRINT : PRINT
4510 RETURN
5000 HTAB 8: INVERSE : PRINT "NUMERICAL MILEAGE ANALYSIS": NORMAL : PRINT
5010 POKE 34,2
5020 IF TF = 0 THEN 4030
5030 GOSUB 6500
5040 ST = FF
5050 RM = 0:RG = 0
5060 IF (LF -FF) <10 THEN EN = LF: GOTO 5080
5070 EN = FF +9
5080 PRINT D$;"READ ";NM$;" MILEAGE.DATA,R";(FF *2 -1)
5090 LM = USR(DU)
5100 FOR I = FF TO EN
5110 G = USR(DU):M = USR(DU)
5120 IF G = 0 THEN A = 0: GOTO 5150
5130 A = (M -LM)/G
5140 RM = RM +(M -LM):RG = RG +G
5150 PRINT "MILEAGE FOR FILL-UP #";I;":";: HTAB 30: PRINT A: PRINT
5160 LM = M
5170 NEXT I
5180 PRINT D$
5190 GOSUB 4500
5200 FF = EN +1
5210 IF (FF -1) <LF THEN 5060
5220 A = RM/RG
5230 PRINT "AVERAGE FOR #";ST;" - ";LF;: HTAB 30: PRINT A: PRINT
5240 GOSUB 5500: GOSUB 3500: GOSUB 4500
5250 POKE 34,0
5260 GOTO 240
5500 DF = (TM/TG) -A
5510 IF DF >0 THEN C$ = " LESS"
5520 IF DF < = 0 THEN C$ = " GREATER"
5530 DF = ABS(DF)
5540 PRINT "THIS AVERAGE IS ";DF;C$
5550 PRINT "THAN THE CAR'S LIFETIME AVERAGE."
5560 PRINT
5570 RETURN
6000 HTAB 8: INVERSE : PRINT "GRAPHICAL MILEAGE ANALYSIS": NORMAL : PRINT
6010 POKE 34,2
6020 IF TF = 0 THEN 4030
6030 GOSUB 6500
6040 IF FF = LF THEN 6030
6050 IF (LF -FF) >139 THEN INVERSE : PRINT "RANGE IS TOO BIG...": NORMAL : GOTO 6030
6060 HOME
6070 HGR : HCOLOR= 3
6080 HPLOT 0,0 TO 0,159 TO 279,159
6090 FOR I = 1 TO 10
6100 HPLOT 0,(160 -(I *16)) TO 3,(160 -(I *16))
6110 NEXT I
6120 DF = LF -FF:IN = INT(279/DF):EN = IN *DF
6130 FOR I = 0 TO EN STEP IN
6140 HPLOT I,155 TO I,159
6150 NEXT I
6160 PRINT D$;"READ ";NM$;" MILEAGE.DATA,R";(FF *2 -1)
6170 LM = USR(DU)
6180 FOR I = 0 TO EN STEP IN
6190 G = USR(DU):M = USR(DU)
6200 IF G = 0 THEN PL = LP: GOTO 6220
6210 A = (M -LM)/G
6220 PL = INT(((HA -A)/(HA -LA)) *159)
6230 IF I = 0 THEN 6250
6240 HPLOT (I -IN),LP TO I,PL
6250 LP = PL:LM = M
6260 NEXT I
6270 PRINT D$
6280 VTAB 21: PRINT "Y-AXIS: MAX. OF": HTAB 9: PRINT HA: HTAB 10: PRINT "MIN. OF": HTAB 9: PRINT LA;
6290 VTAB 21: HTAB 27: PRINT "X-AXIS:": HTAB 27: PRINT FF;" TO ";LF
6300 VTAB 24: HTAB 21: INVERSE : PRINT "ANY KEY FOR AVERAGE";: GET SN$
6310 PL = INT(((HA -(TM/TG))/(HA -LA)) *159): HPLOT 0,PL TO EN,PL
6320 VTAB 24: HTAB 21: PRINT "ANY KEY FOR MENU...";: GET SN$: NORMAL
6330 TEXT : GOTO 240
6500 PRINT "THERE HAVE BEEN ";TF;" FILL-UPS IN THIS"
6510 PRINT "CAR. ANALIZE WHICH ONES? (FIRST,LAST)"
6520 INPUT "RANGE? ";FF,LF
6530 LF = INT(LF):FF = INT(FF)
6540 IF (FF <1) OR (LF >TF) OR (FF >LF) THEN INVERSE : PRINT "BAD RANGE...": NORMAL : GOTO 6520
6550 RETURN
7000 PRINT D$;"CLOSE ";NM$;" MILEAGE.DATA"
7010 VTAB 12: HTAB 19: PRINT "END": PRINT CHR$(4)"RUNMENU"
7020 VTAB 22: PRINT : PRINT CHR$(4)"RUNMENU"